<?php
define('IN_UCHOME', '1');
include_once '../common.php';
$_SGLOBAL['supe_uid'] = 1;

$email = $_REQUEST['e'];
$p = $_REQUEST['p'];
$pwmd5 = md5("sess_picsave_" . $_REQUEST['p'] . "y");

$auth = checkAuth($email, $pwmd5);
if ($auth['status'] == 0) {
	echo $auth['err'];
	exit();
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>网络图片收集</title>
<script type="text/javascript" src="./fancybox/jquery.min.js"></script>
<script type="text/javascript">
	var page=0;
	var index = 0;
	var count = 0;
	function picdel(picid,obj){	
		$.ajax({
			   type: "POST",
			   url: "ajax.php?op=delpic&e=<?php echo $email?>&p=<?php echo $pwmd5;?>",
			   data: {"picid":picid},
			   dataType:'json',
			   success: function(json){
			     if(json.status==1){	
			    	 if(type=='list'&&obj){
			    		 obj.parent().remove();
				     }else{
						window.location.href = window.location.href;	
				     }				    				    
			     }else{
					alert(json.err);
			     }
			   }
			});
	}

	function picload(){
		$("#allPic").css("left",0);
		index = 0;
		$.ajax({
			   type: "POST",
			   url: "ajax.php?op=getpic&e=<?php echo $email?>&p=<?php echo $pwmd5;?>&page="+page,			 
			   dataType:'json',
			   success: function(json){
				 var html = '';
				 var c=0;
			     $.each(json,function(i,v){
					c++;
					html+='<div style="float: left;width:155px;overflow:hidden;">';
					html+='<div class="imgWrap " style="height:150px;">';
					html+='<img alt=""	src="'+v.thumb+'" width="150" height="150" picid="'+v['picid']+'" big="'+v.src+'"/>';
					html+='</div>';
					html+='</div>';
					
			     });
			     count = c;
			     $("#allPic").html(html);
			   }
			});
	}
	$(function(){
		picload();
		$("body").keyup(function(e){
			var key = e.which;		
			//alert(key);	
			$(".imgWrap").removeClass("current");
			if(key==68){
				if(index<count-1){
					index++;
					index = index>count-1?count-1:index;
					$("#allPic").animate({left:"-=155px"}, { duration: 50 });
				}else{
					page++;
					page = page>count-1?count-1:page;
					picload();
				}
				
			}else if(key==65){
				if(index>0){
					index--;
					index = index<0?0:index;
					$("#allPic").animate({left:"+=155px"}, { duration: 50 });
				}else{
					page--;
					page = page<0?0:page;
					picload();
				}			
				
			}
			
			$(".imgWrap").eq(index).addClass("current");
			$("#picshow").append(index);
		});
		
		
		
		
	})
	
</script>
<link href="./css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#wrapper .current{
	border:1px solid red;
}
</style>
<link href="./fancybox/pagination.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div id="wrapper">		
		<div  style="overflow:hidden;width:940px;height:170px;position:relative;">
			<div id="allPic" style="width:20000px;position:absolute;left:0;top:0px;">	
				
					<div style="float: left;width:155px;overflow:hidden;">
						<div style="height:150px;" class="imgWrap ">
							<img width="150" height="150" big="http://www.api.com/api/upload/201208/1/1_1343798198xHx0.jpg" picid="943" src="http://www.api.com/api/upload/201208/1/1_1343798198xHx0.jpg.thumb.jpg" alt="">								
							
						</div>
					</div>
				
					<div style="float: left;width:155px;overflow:hidden;">
						<div style="height:150px;" class="imgWrap ">
							<img width="150" height="150" big="http://www.api.com/api/upload/201208/1/1_13437981991Bs8.jpg" picid="944" src="http://www.api.com/api/upload/201208/1/1_13437981991Bs8.jpg.thumb.jpg" alt="">								
							
						</div>
					</div>
				
					<div style="float: left;width:155px;overflow:hidden;">
						<div style="height:150px;" class="imgWrap ">
							<img width="150" height="150" big="http://www.api.com/api/upload/201208/1/1_13437981974k57.jpg" picid="945" src="http://www.api.com/api/upload/201208/1/1_13437981974k57.jpg.thumb.jpg" alt="">								
							
						</div>
					</div>
				
					<div style="float: left;width:155px;overflow:hidden;">
						<div style="height:150px;" class="imgWrap ">
							<img width="150" height="150" big="http://www.api.com/api/upload/201208/1/1_1343798200lXa7.jpg" picid="946" src="http://www.api.com/api/upload/201208/1/1_1343798200lXa7.jpg.thumb.jpg" alt="">								
							
						</div>
					</div>
					
			</div>
		</div>	
		<div id="picshow">
			
		</div>
		<div style="display:none;clear:both;">		
			<?php echo $multi;?>	
		</div>
		
		
		<div  style="display:none;clear:both;">
			<a
				href="picupload.php?e=<?php echo $_GET['e']?>&p=<?php echo $_GET['p']?>">图片上传</a>&nbsp;
			<a
				href="index.php?e=<?php echo $_GET['e']?>&p=<?php echo $_GET['p']?>&page=<?php echo $page;?>">首页缩略图</a>&nbsp;
			<a
				href="index.php?e=<?php echo $_GET['e']?>&p=<?php echo $_GET['p']?>&type=list&page=<?php echo $page;?>">首页大图列表</a>
		</div>
	</div>
</body>
</html>